<template>
  <div>
    <mt-header title="我的二维码" fixed>
      <router-link to="/" slot="left">
        <mt-button icon="back">返回</mt-button>
      </router-link>
    </mt-header>
    <div class="code" v-show="show">
      <img :src="src" alt="二维码" width="200" ref="code">
      <div class="bottom">
        扫描二维码加入商城
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'q-r-code',
  data () {
    return {
      src: '',
      show: false
    }
  },
  methods: {},
  created () {
    this.$ajax.post('/agent/qrcode/create')
      .then(res => {
        this.src = res.data.data
      })
  },
  mounted () {
    this.$refs.code.onload = () => {
      this.show = true
    }
  }
}
</script>

<style scoped>
  .code{
    width: 200px;
    margin: 100px auto;
    padding: 16px;
  }
  .bottom{
    text-align: center;
    line-height: 30px;
    color: #909399;
  }
</style>
